<?php
if (! defined ( 'BASEPATH' ))
	exit ( 'No direct script access allowed' );

class Storelist extends CI_Controller {
	
	function __construct() {
		parent::__construct ();
	
	}
	
	public function index() {
		$eData = array();
		$type  = $this->uri->segment(2);
		$code  = (int)$this->uri->segment(3);
		$orderby  = $this->input->get('orderby');
		if($orderby == null){
			$orderby = 'createTime';
		}
		$ePage = ( int ) $this->input->get ('page' );
		if($type == 'shenghuo' || $type=='fushi' || $type == 'wenhua' || $type == 'xiuxian' || $type=='meishi'){
			$this->db->where('storetype',$type);
			$this->db->where('storetypes',$code);
			$this->db->order_by($orderby, 'DESC');
			$this->db->limit(7,$ePage);
			$eData['storelist'] = $this->db->get('store')->result_array();
			$this->db->where('storetype',$type);
			$this->db->where('storetypes',$code);
			$eData ['storelistCount'] = $this->db->count_all_results('store');
		}else if($type=='ycpp'){
			$this->db->where('storebrand',$code);
			$this->db->order_by($orderby, 'DESC');
			$this->db->limit(7,$ePage);
			$eData['storelist'] = $this->db->get('store')->result_array();
			$this->db->where('storebrand',$code);
			$eData ['storelistCount'] = $this->db->count_all_results('store');
		}else if($type=='tsqy' || $type=='yishu' || $type=='ditie'){
			$this->db->where('storespebus',$type);
			$this->db->where('storespebuss',$code);
			$this->db->order_by($orderby, 'DESC');
			$this->db->limit(7,$ePage);
			$eData['storelist'] = $this->db->get('store')->result_array();
			$this->db->where('storespebus',$type);
			$this->db->where('storespebuss',$code);
			$eData ['storelistCount'] = $this->db->count_all_results('store');
		}
		
		$this->db->where('name',$type);
		$this->db->where('code',$code);
		
		$eData['codevalue'] = $this->db->get('codevalue')->row_array();
		$this->load->library ( 'pagination' );
		$eConfig ['per_page'] = 7;
		$eConfig ['num_links'] = 7;
		$eConfig ['base_url'] = site_url ( 'storelist/'.$type.'/'.$code.'?1=1');
		$eConfig ['total_rows'] = $eData ['storelistCount'];
		$eConfig ['first_link'] = false;
		$eConfig ['last_link'] = false;
		$eConfig ['next_link'] = '下一页';
		$eConfig ['next_tag_open'] = '<li>';
		$eConfig ['next_tag_close'] = '</li>';
		$eConfig ['prev_link'] = '上一页';
		$eConfig ['prev_tag_open'] = '<li>';
		$eConfig ['prev_tag_close'] = '</li>';
		$eConfig ['num_tag_open'] = '<li>';
		$eConfig ['num_tag_close'] = '</li>';
		$eConfig ['cur_tag_open'] = '<li class="current"><a href="#">';
		$eConfig ['cur_tag_close'] = '</a></li>';
		$this->pagination->initialize ( $eConfig );
		
		$this->load->view ( 'storelist', $eData );
	}
	
	
	
}

